package com.sgb.kjwl.utils;

import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.text.InputFilter;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.luck.picture.lib.photoview.PhotoView;
import com.sgb.kjwl.R;
import com.sgb.kjwl.view.ui.activity.self.authentication.AuthActivity3;
import com.sgb.kjwl.view.ui.activity.self.userInfo.VerificationCodeLoginActivity;
import com.swgk.core.dialog.RoundCornerDialog;
import com.swgk.core.customview.InputFilterUtils;
import com.swgk.core.dialog.RoundDialog;
import com.swgk.core.util.MToast;
import com.swgk.core.util.SharedPreferenceUtil;

import java.util.ArrayList;
import java.util.List;

import androidx.cardview.widget.CardView;

/**
 * @author younghow
 * @date 2020/10/29
 * description：针对与dialog的一些通用设置
 * first:写在前面，我们在命名的时候一定采用驼峰的方式
 * second:在命名的时候一定要做到代码自解释，也就是说我们用翻译就大概知道这个是要干嘛的
 */
public class DialogHelper {

    private static AlertDialog mDialog;

    /**
     * 弹出框设置,罪通常的dialog，分为标题，内容，左右案件，圆角
     * @param context 上下文
     * @param title 弹出框标题
     * @param message 弹出框内容
     * @param positiveStr 确定按钮
     * @param dialogFunction 确定键回调
     */
    public static void showDialog(Context context, String title, String message, String positiveStr, DialogFunction dialogFunction) {
        View view = View.inflate(context, R.layout.dialog_two_btn_circle, null);
        final RoundCornerDialog roundCornerDialog = new RoundCornerDialog(context, 0, 0, view, R.style.RoundCornerDialog);
        roundCornerDialog.show();
        roundCornerDialog.setCanceledOnTouchOutside(false);

        TextView tvTitle = view.findViewById(R.id.tv_title);
        TextView tvMessage = view.findViewById(R.id.tv_message);
        TextView tvLogoutConfirm = view.findViewById(R.id.tv_logout_confirm);
        TextView tvLogoutCancel = view.findViewById(R.id.tv_logout_cancel);
        if (title != null) {
            tvTitle.setVisibility(View.VISIBLE);
            tvTitle.setText(title);
        } else {
            tvTitle.setVisibility(View.GONE);
        }

        if (message != null) {
            tvMessage.setVisibility(View.VISIBLE);
            tvMessage.setText(message);
        } else {
            tvMessage.setVisibility(View.GONE);
        }

        if(!TextUtils.isEmpty(positiveStr)){
            tvLogoutConfirm.setText(positiveStr);
        }
        //确定
        tvLogoutConfirm.setOnClickListener(v -> {
            dialogFunction.normalRoundDialog();
            roundCornerDialog.dismiss();

        });
        //取消
        tvLogoutCancel.setOnClickListener(v -> roundCornerDialog.dismiss());
    }


    /**
     * 取消、确定按键 都可重新设置文本
     * @param context
     * @param title 标题
     * @param message 信息
     * @param negativeStr 左边键文本
     * @param positiveStr 右边键文本
     * @param dialogFunction 右边键回调
     */
    public static void showDialog(Context context, String title, String message, String negativeStr, String positiveStr, DialogFunction dialogFunction) {
        View view = View.inflate(context, R.layout.dialog_two_btn, null);
        final RoundCornerDialog roundCornerDialog = new RoundCornerDialog(context, 0, 0, view, R.style.RoundCornerDialog);
        roundCornerDialog.show();
        roundCornerDialog.setCanceledOnTouchOutside(false);

        TextView tvTitle = view.findViewById(R.id.tv_title);
        TextView tvMessage = view.findViewById(R.id.tv_message);
        TextView tvLogoutConfirm = view.findViewById(R.id.tv_logout_confirm);
        TextView tvLogoutCancel = view.findViewById(R.id.tv_logout_cancel);
        if (title != null) {
            tvTitle.setVisibility(View.VISIBLE);
            tvTitle.setText(title);
        } else {
            tvTitle.setVisibility(View.GONE);
        }

        if (message != null) {
            tvMessage.setVisibility(View.VISIBLE);
            tvMessage.setText(message);
        } else {
            tvMessage.setVisibility(View.GONE);
        }

        if (negativeStr != null) {
            tvLogoutCancel.setVisibility(View.VISIBLE);
            tvLogoutCancel.setText(negativeStr);
        } else {
            tvLogoutCancel.setVisibility(View.GONE);
        }

        if (positiveStr != null) {
            tvLogoutConfirm.setVisibility(View.VISIBLE);
            tvLogoutConfirm.setText(positiveStr);
        } else {
            tvLogoutConfirm.setVisibility(View.GONE);
        }

        //确定
        tvLogoutConfirm.setOnClickListener(v -> {
            dialogFunction.normalRoundDialog();
            roundCornerDialog.dismiss();
        });

        //取消
        tvLogoutCancel.setOnClickListener(v -> roundCornerDialog.dismiss());
    }


    /**
     * 取消、确定按键 都可重新设置文本
     * @param context
     * @param title 标题
     * @param message 信息
     * @param negativeStr 左边键文本
     * @param positiveStr 右边键文本
     * @param dialogFunction 右边键回调
     * @param dialogFunction2 左边键回调
     */
    public static void showDialog(Context context, String title, String message, String negativeStr, String positiveStr, DialogFunction dialogFunction,DialogFunction dialogFunction2) {
        View view = View.inflate(context, R.layout.dialog_two_btn, null);
        final RoundCornerDialog roundCornerDialog = new RoundCornerDialog(context, 0, 0, view, R.style.RoundCornerDialog);
        roundCornerDialog.show();
        roundCornerDialog.setCanceledOnTouchOutside(false);

        TextView tvTitle = view.findViewById(R.id.tv_title);
        TextView tvMessage = view.findViewById(R.id.tv_message);
        TextView tvLogoutConfirm = view.findViewById(R.id.tv_logout_confirm);
        TextView tvLogoutCancel = view.findViewById(R.id.tv_logout_cancel);
        if (title != null) {
            tvTitle.setVisibility(View.VISIBLE);
            tvTitle.setText(title);
        } else {
            tvTitle.setVisibility(View.GONE);
        }

        if (message != null) {
            tvMessage.setVisibility(View.VISIBLE);
            tvMessage.setText(message);
        } else {
            tvMessage.setVisibility(View.GONE);
        }

        if (negativeStr != null) {
            tvLogoutCancel.setVisibility(View.VISIBLE);
            tvLogoutCancel.setText(negativeStr);
        } else {
            tvLogoutCancel.setVisibility(View.GONE);
        }

        if (positiveStr != null) {
            tvLogoutConfirm.setVisibility(View.VISIBLE);
            tvLogoutConfirm.setText(positiveStr);
        } else {
            tvLogoutConfirm.setVisibility(View.GONE);
        }

        //确定
        tvLogoutConfirm.setOnClickListener(v -> {
            dialogFunction.normalRoundDialog();
            roundCornerDialog.dismiss();
        });

        //取消
        tvLogoutCancel.setOnClickListener(v ->{
            dialogFunction2.normalRoundDialog();
            roundCornerDialog.dismiss();
        });
    }


    /**
     * 验证token是否为空
     */
    public static boolean checkLogin() {
        return !TextUtils.isEmpty(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LOGIN_TOKEN, ""));
    }

    /**
     * 登录弹框
     */
    public static void showLoginDialog(Context context,int whereJump) {
        View view = View.inflate(context, R.layout.dialog_two_btn, null);
        final RoundCornerDialog roundCornerDialog = new RoundCornerDialog(context, 0, 0, view, R.style.RoundCornerDialog);
        roundCornerDialog.show();
        roundCornerDialog.setCanceledOnTouchOutside(false);
        TextView tvMessage = view.findViewById(R.id.tv_message);
        TextView tvTitle = view.findViewById(R.id.tv_title);
        TextView tvLogoutConfirm = view.findViewById(R.id.tv_logout_confirm);
        TextView tvLogoutCancel = view.findViewById(R.id.tv_logout_cancel);
        tvMessage.setText("请登录后再试");
        tvTitle.setText("去登录");
        tvTitle.setVisibility(View.VISIBLE);
        //确定
        tvLogoutConfirm.setOnClickListener(v -> {
            VerificationCodeLoginActivity.start(context,whereJump);
            roundCornerDialog.dismiss();
        });
        //取消
        tvLogoutCancel.setOnClickListener(v -> roundCornerDialog.dismiss());
    }

    /**
     * 图片预览
     * @param context 上下文
     * @param uri 图片的地址
     */
    public static void showPicturePreview(Context context,Object uri){
        View contentView = LayoutInflater.from(context).inflate(R.layout.layout_sample_pic, null);
        final RoundCornerDialog roundCornerDialog = new RoundCornerDialog(context, 0, 0, contentView, R.style.RoundCornerDialog);
        Window window = roundCornerDialog.getWindow();
        WindowManager.LayoutParams params = window.getAttributes();
        params.height = WindowManager.LayoutParams.WRAP_CONTENT;
        params.width = WindowManager.LayoutParams.WRAP_CONTENT;
        window.setAttributes(params);
        roundCornerDialog.show();
        roundCornerDialog.setCanceledOnTouchOutside(true);
        PhotoView imageView = contentView.findViewById(R.id.sample_pic);
        Glide.with(context).load(uri).into(imageView);
        imageView.setOnViewTapListener((view, x, y) -> roundCornerDialog.dismiss());
    }

    /**
     * 圆角的弹出框，下载的dialog
     * @param context 上下文
     */
    public static void showDownloadDialog(Context context) {
        if (isAvilible(context, "com.zjkj.driver")) {
            Intent intent = context.getPackageManager().getLaunchIntentForPackage("com.zjkj.driver");
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(intent);
        } else {
            new RoundDialog.Builder(context)
                    .title("下载提示")
                    .content("更多功能请下载经营帮货运APP，\n去下载？")
                    .cancel("取消")
                    .confirm("确定")
                    .contentGravity(Gravity.CENTER)
                    .cancelable(false)
                    .confirmCallback(v -> {
                        Uri uri = Uri.parse("https://a.app.qq.com/o/simple.jsp?pkgname=com.zjkj.driver");
                        Intent intent = new Intent(Intent.ACTION_VIEW);
                        intent.setData(uri);
                        context.startActivity(intent);
                    })
                    .show();
        }

    }

    /**
     * 检查手机上是否安装了指定的软件
     *
     * @param context 上下文
     * @param packageName：应用包名
     * @return
     */
    public static boolean isAvilible(Context context, String packageName) {
        PackageManager packageManager = context.getPackageManager();
        List<PackageInfo> packageInfos = packageManager.getInstalledPackages(0);
        List<String> packageNames = new ArrayList<String>();
        if (packageInfos != null) {
            for (int i = 0; i < packageInfos.size(); i++) {
                String packName = packageInfos.get(i).packageName;
                packageNames.add(packName);
            }
        }
        return packageNames.contains(packageName);
    }

    /**
     *
     * @param context 上下文
     * @param content 1.标题，2.内容，3.确定标题
     */
    public static void showLoginDialogNew(Context context,int whereJump, String...content) {
        View view = View.inflate(context, R.layout.dialog_two_btn_circle, null);
        final RoundCornerDialog roundCornerDialog = new RoundCornerDialog(context, 0, 0, view, R.style.RoundCornerDialog);
        roundCornerDialog.show();
        // 设置点击屏幕Dialog不消失
        roundCornerDialog.setCanceledOnTouchOutside(false);
        TextView tv_message = view.findViewById(R.id.tv_message);
        TextView tv_title = view.findViewById(R.id.tv_title);
        TextView tv_logout_confirm = view.findViewById(R.id.tv_logout_confirm);
        TextView tv_logout_cancel = view.findViewById(R.id.tv_logout_cancel);
        tv_message.setText(content[1]);
        tv_title.setText(content[0]);
        tv_logout_confirm.setText(content[2]);
        tv_title.setVisibility(View.VISIBLE);
        //确定
        tv_logout_confirm.setOnClickListener(v -> {
            VerificationCodeLoginActivity.start(context,whereJump);
            roundCornerDialog.dismiss();
        });
        //取消
        tv_logout_cancel.setOnClickListener(v -> roundCornerDialog.dismiss());
    }

    public static void showAuthenDialog(Context mContext,int type) {
        LayoutInflater inflater = LayoutInflater.from(mContext);
        View layout;

        AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
        switch (type) {
            //司机认证提醒切换
            case 2:
                layout = inflater.inflate(R.layout.dialog_authen_driver_change, null);
                layout.findViewById(R.id.rl_authen_driver).setOnClickListener(view -> {
                    AuthActivity3.start(mContext);
                    mDialog.dismiss();
                });
                break;
            //货主中介认证
            case 3:
                layout = inflater.inflate(R.layout.dialog_authen_owner_zhongjie_change, null);
                layout.findViewById(R.id.rl_authen_owner).setOnClickListener(view -> {
                    AuthActivity3.start(mContext);
                    mDialog.dismiss();
                });
                layout.findViewById(R.id.rl_authen_zhongjie).setOnClickListener(view -> {
                    AuthActivity3.start(mContext);
                    mDialog.dismiss();
                });
                break;
            //司机认证
            case 1:
            default:
                layout = inflater.inflate(R.layout.dialog_authen_driver, null);
                layout.findViewById(R.id.rl_authen_driver).setOnClickListener(view -> {
                    AuthActivity3.start(mContext);
                    mDialog.dismiss();
                });
        }

        builder.setView(layout);
        builder.setCancelable(true);
        mDialog = builder.show();
        mDialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);

        DisplayMetrics dm = new DisplayMetrics();
        //获取屏幕信息
        dm =mContext.getResources().getDisplayMetrics();
        int screenWidth = dm.widthPixels;
        int screenHeigh = dm.heightPixels;
        CardView cv = mDialog.findViewById(R.id.cv_dialog);
        //取控件textView当前的布局参数
        LinearLayout.LayoutParams linearParams = (LinearLayout.LayoutParams) cv.getLayoutParams();
        linearParams.width = screenWidth - 100;
        cv.setLayoutParams(linearParams);

        mDialog.findViewById(R.id.iv_cancel).setOnClickListener(v -> mDialog.dismiss());

    }

    public static void showPayDialog(Context mContext,String allFreight,String address,DialogClick dialogClick) {
        LayoutInflater inflater = LayoutInflater.from(mContext);
        View layout;

        AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
        layout = inflater.inflate(R.layout.dialog_collection_qr_code, null);
        TextView textView =layout.findViewById(R.id.qr_code_pay_freight_text);
        RelativeLayout weiXin=layout.findViewById(R.id.ll_qr_code_pay_weixin);
        RelativeLayout zhiFb=layout.findViewById(R.id.ll_qr_code_pay_zhifubao);
        textView.setText(allFreight+"元");
        TextView tv_address = layout.findViewById(R.id.qr_code_address);
        tv_address.setText(address);
        weiXin.setOnClickListener(view -> {
            dialogClick.dialogClick1(); mDialog.dismiss();
        });

        zhiFb.setOnClickListener(view -> {
            dialogClick.dialogClick2(); mDialog.dismiss();

        });
        layout.findViewById(R.id.iv_cancel).setOnClickListener(v -> mDialog.dismiss());
        builder.setView(layout);
        builder.setCancelable(true);
        mDialog = builder.show();
        mDialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
        DisplayMetrics dm = new DisplayMetrics();
        //获取屏幕信息
        dm =mContext.getResources().getDisplayMetrics();
        int screenWidth = dm.widthPixels;
        int screenHeigh = dm.heightPixels;
        CardView cv = mDialog.findViewById(R.id.cv_dialog);
        LinearLayout.LayoutParams linearParams = (LinearLayout.LayoutParams) cv.getLayoutParams();
        linearParams.width = screenWidth - 200;
        cv.setLayoutParams(linearParams);
        mDialog.findViewById(R.id.iv_cancel).setOnClickListener(v -> mDialog.dismiss());

    }

    /**
     * 显示弹框，弹框样式为，右上角一个x，标题和内容
     * @param context
     * @param title
     * @param message
     * @param dialogFunction
     */
    public static void showDialog(Context context, String title, String message, DialogFunction dialogFunction) {
        View view = View.inflate(context, R.layout.dialog_close_btn_circle, null);
        final RoundCornerDialog roundCornerDialog = new RoundCornerDialog(context, 0, 0, view, R.style.RoundCornerDialog);
        roundCornerDialog.show();
        roundCornerDialog.setCanceledOnTouchOutside(false);

        TextView tv_title = view.findViewById(R.id.tv_title);
        TextView tv_message = view.findViewById(R.id.tv_message);
        ImageView close_btn = view.findViewById(R.id.iv_close);

        if (message != null) {
            tv_title.setVisibility(View.VISIBLE);
            tv_title.setText(title);
        } else {
            tv_title.setVisibility(View.GONE);
        }

        if (message != null) {
            tv_message.setVisibility(View.VISIBLE);
            tv_message.setText(message);
        } else {
            tv_message.setVisibility(View.GONE);
        }

        //确定
        close_btn.setOnClickListener(v -> {
            dialogFunction.normalRoundDialog();
            roundCornerDialog.dismiss();

        });
    }

    public static void showSingleDialog(Context context, String title, String message, String postiveText, boolean titleVisiable, DialogFunction dialogFunction) {
        View view = View.inflate(context, R.layout.dialog_one_btn, null);
        final RoundCornerDialog roundCornerDialog = new RoundCornerDialog(context, 0, 0, view, R.style.RoundCornerDialog);
        roundCornerDialog.show();
        roundCornerDialog.setCanceledOnTouchOutside(false);

        TextView tv_title = view.findViewById(R.id.tv_title);
        TextView tv_message = view.findViewById(R.id.tv_message);
        TextView tv_logout_confirm = view.findViewById(R.id.tv_logout_confirm);
        if (titleVisiable) {
            tv_title.setVisibility(View.VISIBLE);
            if (title != null) {
                tv_title.setVisibility(View.VISIBLE);
                tv_title.setText(title);
            } else {
                tv_title.setVisibility(View.GONE);
            }
        } else {
            tv_title.setVisibility(View.GONE);
        }


        if (message != null) {
            tv_message.setVisibility(View.VISIBLE);
            tv_message.setText(message);
        } else {
            tv_message.setVisibility(View.GONE);
        }
        if (postiveText != null) {
            tv_logout_confirm.setText(postiveText);
        }


        //确定
        tv_logout_confirm.setOnClickListener(v -> {
            dialogFunction.normalRoundDialog();
            roundCornerDialog.dismiss();

        });
    }

    /**
     * 取消、确定按键 都可重新设置文本 工队报名确定信息 双列的dialog
     * @param context 上下文
     * @param title 标题
     * @param messageTitle 双列的标题
     * @param messageContent 双列的内容 (与标题一一对应，个数需要一样以上到下排列)
     * @param negativeStr 左边键文本
     * @param positiveStr 右边键文本
     * @param dialogFunction 右边键回调
     */
    public static void showDialogForTeam(Context context, String title, String[] messageTitle,String[] messageContent, String negativeStr, String positiveStr, DialogFunction dialogFunction) {
        View view = View.inflate(context, R.layout.dialog_three_line_two_btn, null);
        final RoundCornerDialog roundCornerDialog = new RoundCornerDialog(context, 0, 0, view, R.style.RoundCornerDialog);
        roundCornerDialog.show();
        // 设置点击屏幕Dialog不消失
        roundCornerDialog.setCanceledOnTouchOutside(false);

        TextView tv_title = view.findViewById(R.id.tv_title);
        TextView tv_message_title = view.findViewById(R.id.tv_message_title);
        TextView tv_message_content = view.findViewById(R.id.tv_message_content);
        TextView tv_logout_confirm = view.findViewById(R.id.tv_logout_confirm);
        TextView tv_logout_cancel = view.findViewById(R.id.tv_logout_cancel);
        if (title != null) {
            tv_title.setVisibility(View.VISIBLE);
            tv_title.setText(title);
        } else {
            tv_title.setVisibility(View.GONE);
        }

        StringBuilder titleStr = new StringBuilder();
        StringBuilder contentStr = new StringBuilder();
        for (int i = 0; i < messageTitle.length; i++) {
            if (i == 0){
                titleStr.append(messageTitle[i]);
                contentStr.append(messageContent[i]);
                continue;
            }
            titleStr.append("\n").append(messageTitle[i]);
            contentStr.append("\n").append(messageContent[i]);
        }

        tv_message_title.setText(titleStr.toString());
        tv_message_content.setText(contentStr.toString());
        if (negativeStr != null) {
            tv_logout_cancel.setVisibility(View.VISIBLE);
            tv_logout_cancel.setText(negativeStr);
        } else {
            tv_logout_cancel.setVisibility(View.GONE);
        }

        if (positiveStr != null) {
            tv_logout_confirm.setVisibility(View.VISIBLE);
            tv_logout_confirm.setText(positiveStr);
        } else {
            tv_logout_confirm.setVisibility(View.GONE);
        }

        //确定
        tv_logout_confirm.setOnClickListener(v -> {
            dialogFunction.normalRoundDialog();
            roundCornerDialog.dismiss();
        });

        //取消
        tv_logout_cancel.setOnClickListener(v -> roundCornerDialog.dismiss());
    }

    public interface DialogClick{
        default void dialogClick1(){

        }

        default void dialogClick2(){

        }
    }

    /**
     * 弹出框设置,罪通常的dialog，分为标题，内容，左右案件，圆角
     * @param context 上下文
     * @param contentStr 实质的内容，这个地方也需要采用一一对应的关系，第一个为标题，第二个为内容，第三个为确定按钮，第四个为取消按钮，皆为文本需求
     * @param dialogFunction 确定键回调
     */
    public static void showDialog(Context context, DialogFunction dialogFunction,String...contentStr) {
        View view = View.inflate(context, R.layout.dialog_two_btn_circle, null);
        final RoundCornerDialog roundCornerDialog = new RoundCornerDialog(context, 0, 0, view, R.style.RoundCornerDialog);
        roundCornerDialog.show();
        roundCornerDialog.setCanceledOnTouchOutside(false);

        TextView tvTitle = view.findViewById(R.id.tv_title);
        TextView tvMessage = view.findViewById(R.id.tv_message);
        TextView tvLogoutConfirm = view.findViewById(R.id.tv_logout_confirm);
        TextView tvLogoutCancel = view.findViewById(R.id.tv_logout_cancel);
        for (int i = 0; i < contentStr.length; i++) {
            if (i == 0){
                if (contentStr[i] != null) {
                    tvTitle.setText(contentStr[i]);
                    tvTitle.setVisibility(View.VISIBLE);
                }else {
                    tvTitle.setVisibility(View.GONE);
                }
            }

            if (i == 1){
                if (contentStr[i] != null) {
                    tvMessage.setText(contentStr[i]);
                    tvMessage.setVisibility(View.VISIBLE);
                }else {
                    tvMessage.setVisibility(View.GONE);
                }
            }

            if (i == 2){
                if (contentStr[i] != null) {
                    tvLogoutConfirm.setText(contentStr[i]);
                    tvLogoutConfirm.setVisibility(View.VISIBLE);
                }else {
                    tvLogoutConfirm.setVisibility(View.GONE);
                    tvLogoutConfirm.setText("确定");
                }
            }

            if (i == 3){
                if (contentStr[i] != null) {
                    tvLogoutCancel.setText(contentStr[i]);
                    tvLogoutCancel.setVisibility(View.VISIBLE);
                }else {
                    tvLogoutCancel.setVisibility(View.GONE);
                    tvLogoutCancel.setText("取消");
                }
            }
        }

        //确定
        tvLogoutConfirm.setOnClickListener(v -> {
            dialogFunction.normalRoundDialog();
            roundCornerDialog.dismiss();
        });

        //取消
        tvLogoutCancel.setOnClickListener(v -> roundCornerDialog.dismiss());
    }


    /**
     * 可输入的dialog
     * @param context 上下文
     * @param dialogTextReturnValue 回调接口
     * @param title  标题
     * @param inputtext 输入框输入值
     * @param labeltext 输入框标题
     * @param inputhint 输入框hint提示
     * @param showstart 是否必填
     */
    public static void showDialog(Context context, DialogTextReturnValue dialogTextReturnValue ,String title,String inputtext,String labeltext,String inputhint,boolean showstart,Integer maxtextsize){
        View view = View.inflate(context, R.layout.dialog_show_inputdialog, null);
        final RoundCornerDialog roundCornerDialog = new RoundCornerDialog(context, 0, 0, view, R.style.RoundCornerDialog);
        roundCornerDialog.show();
        roundCornerDialog.setCanceledOnTouchOutside(false);

        TextView tvTitle = view.findViewById(R.id.tv_title);
        TextView tvLabel = view.findViewById(R.id.tv_label);
        TextView tvStart = view.findViewById(R.id.tv_start);
        EditText eidInputdata = view.findViewById(R.id.eid_inputdata);
        TextView tvLogoutConfirm = view.findViewById(R.id.tv_logout_confirm);
        TextView tvLogoutCancel = view.findViewById(R.id.tv_logout_cancel);
        eidInputdata.setFilters(new InputFilter[]{});

        tvTitle.setText(TextUtils.isEmpty(title)?"":title);
        tvLabel.setText(TextUtils.isEmpty(labeltext)?"":labeltext);
        tvStart.setVisibility(showstart?View.VISIBLE:View.GONE);
        eidInputdata.setHint(TextUtils.isEmpty(inputhint)?"":inputhint);
        if(!TextUtils.isEmpty(inputtext)){
            eidInputdata.setText(inputtext);
        }
        if(maxtextsize!=null){
            InputFilterUtils.setEditTextInhibitInputSpaChat(eidInputdata, maxtextsize);
        }
        //确定
        tvLogoutConfirm.setOnClickListener(v -> {
            if(!TextUtils.isEmpty(eidInputdata.getText().toString().trim())) {
                dialogTextReturnValue.returnvalue(eidInputdata.getText().toString().trim().replace(" ",""),roundCornerDialog);

            }else{
                if(showstart) {
                    MToast.showLongToast(context, inputhint);
                }else{
                    dialogTextReturnValue.returnvalue(eidInputdata.getText().toString().trim().replace(" ",""),roundCornerDialog);
                }
            }
        });

        //取消
        tvLogoutCancel.setOnClickListener(v -> roundCornerDialog.dismiss());

    }


}
